package Algorithms.chapter1;

public class Ex9 {
    public static char[] toBinaryString(int value){
        if(value ==0){
            char[] result=new char[1];
            result[0]= (char)('0');
            return result;
        }
//典型换算方法
        int N = value;
        int ind = 0;
        int ind2 = 0;
        char[] result=new char[32];
        char[] temp = new char[32];
        for(int i=N;i>=1;i=i/2){
            result[ind] = (char) ('0'+i%2);
            ind++;
        }
        //矩阵倒置
        for(int i = ind-1;i!=0;i--){
            temp[ind2]=result[i];
            ind2++;
        }
        return temp;
    }

    public static void main(String[] args) {
        int value = 50;
        System.out.print(toBinaryString(value));


    }

}
